package org.proddevplm.business.administration;

import java.util.HashMap;
import java.util.Map;

import org.proddevplm.business.administration.constants.AdminConstants;
import org.proddevplm.business.api.IAdapter;
import org.proddevplm.helpers.ManagerUtil;

public class AdminAdapter implements IAdapter{

	@Override
	public Object adapt(int command, Map<String, Object> dataObject) {

		Object adaptedObject = null;
		Map<String, Object> adminMap = new HashMap<String, Object>();
		
		switch (command){
		
		case AdminConstants.SET_ACCESS_LEVEL:
			adminMap.put("accessLevel", ManagerUtil.getStringFromReq(dataObject.get("accessLevel")));
			adminMap.put("roleId", ManagerUtil.getStringFromReq(dataObject.get("roleId")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.EDIT_ACCESS_LEVELS:
			adminMap.put("accessLevelId", ManagerUtil.getStringFromReq(dataObject.get("accessLevelId")));
			adminMap.put("newLevel", ManagerUtil.getStringFromReq(dataObject.get("newLevel")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.ADD_ROLES:
			String list = ManagerUtil.getStringFromReq(dataObject.get("rolesList"));
			String[] rolesArray = list.split("~");
			adminMap.put("rolesArray", rolesArray);
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.ADD_DFX:
			adminMap.put("newDfX", ManagerUtil.getStringFromReq(dataObject.get("newDfX")));
			adminMap.put("dfXDetailedInfo", ManagerUtil.getStringFromReq(dataObject.get("dfXDetailedInfo")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.EDIT_DFX:
			adminMap.put("dfxId", ManagerUtil.getStringFromReq(dataObject.get("dfxId")));
			adminMap.put("dfxName", ManagerUtil.getStringFromReq(dataObject.get("editDfXName")));
			adminMap.put("dfxDetailedInfo", ManagerUtil.getStringFromReq(dataObject.get("editDfXDetailedInfo")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.GET_DFX:
			adminMap.put("dfxId", ManagerUtil.getStringFromReq(dataObject.get("dfxId")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.GET_GUIDELINES:
			adminMap.put("dfxId", ManagerUtil.getStringFromReq(dataObject.get("dfxId")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.GET_SPECFIC_GUIDELINE:
			adminMap.put("dfxGId", ManagerUtil.getStringFromReq(dataObject.get("dfxGId")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.UPDATE_GUIDELINE:
			adminMap.put("dfxGId", ManagerUtil.getStringFromReq(dataObject.get("dfxGId")));
			adminMap.put("guidelineDetails", ManagerUtil.getStringFromReq(dataObject.get("guidelineDetails")));
			
			adaptedObject = adminMap;
			break;
			
		case AdminConstants.ADD_GUIDELINE:
			adminMap.put("dfxId", ManagerUtil.getStringFromReq(dataObject.get("dfxId")));
			adminMap.put("guidelineName", ManagerUtil.getStringFromReq(dataObject.get("guideline")));
			adminMap.put("guidelineDetails", ManagerUtil.getStringFromReq(dataObject.get("details")));
			
			adaptedObject = adminMap;
			break;
		}
		return adaptedObject;
	}

}
